﻿'use strict';
(function () {
    // 注意JS的绑定顺序，第一组绑定的文件可以用angular.module('MyControllers', []);，后续的文件只能用angular.module('MyControllers')
    var service = angular.module('MyServices');

    service.factory('configService', ['$http', function (http) {
        var methods = {
            loginSrv: {
                // 登录
                login: function (username, password) {
                    return http.post('/Manager/Login', { account: username, password: password });
                }
            },

            updateSrv: {
                // 检测连网状态
                checkForOnLine: function () {
                    return http.post('/Login/CheckForOnLine');
                },
                // 检测最新版本
                checkForUpdate: function () {
                    return http.post('/Login/CheckForUpdate');
                },
                // 进行简单更新
                updateForSimple: function (version) {
                    return http.post('/Login/SimpleTest', { version: version });
                },
                // 进行必要更新
                updateForNecessary: function (version) {
                    return http.post('/Login/UpdateForNecessary', { version: version });
                }
            },

            configSrv: {
                // 测试连接
                connectTest: function (url) {
                    return http.post('/Login/ConnectTest', { serverUrl: url });
                },
                // 验证网考服务器batchCode及Code
                verification: function (batchCode, code) {
                    return http.post('/Login/Verification', { batchCode: batchCode, validateCode: code });
                },
                // 设置考点信息
                setExamSite: function (app, site) {
                    return http.post('/Login/SetExamSite', { app: app, site: site });
                },
                // 修改考点密码
                updatePwd: function (site) {
                    return http.post('/Login/UpdatePwd', site);
                }
            },

            setCurSrv: {
                // 获取网考服务器列表
                getAppList: function (siteId) {
                    return http.post('/Login/GetAppList', { siteId: siteId });
                },
                // 设置当前网考主办方
                setCurApp: function (appId, siteId) {
                    return http.post('/Login/SetCurApp', { appId: appId, siteId: siteId });
                }
            }
        };
        return methods;
    }]);
})();